package com.hcms.system.service.impl;

import com.hcms.system.dao.AdminDao;
import com.hcms.system.domain.AdminDo;
import com.hcms.system.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminDao adminMapper;

    @Override
    public AdminDo get(Integer id) {
        AdminDo adminDo = adminMapper.get(id);
        return adminDo;
    }

    @Override
    public List<AdminDo> list(Map<String, Object> map) {
        List<AdminDo> admins = adminMapper.list(map);
        return admins;
    }

    @Override
    public int count(Map<String, Object> map) {
        int count = adminMapper.count(map);
        return count;
    }

    @Override
    public int save(AdminDo admin) {
        Date date = new Date();
        admin.setCreateTime(date);
        admin.setUpdateTime(date);
        int result = adminMapper.save(admin);
        return result;
    }

    @Override
    public int update(AdminDo admin) {
        admin.setUpdateTime(new Date());
        int result = adminMapper.update(admin);
        return result;
    }
}
